﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using BrnMall.Core;
using BrnMall.Manager.Domain.Restaurant;

namespace QIDong.WeApp.Models
{
    /// <summary>
    /// 确认订单模型类
    /// </summary>
    public class ConfirmOrderModel
    {
        /// <summary>
        /// 选中的购物车项键列表
        /// </summary>
        public string SelectedCartItemKeyList { get; set; }

        /// <summary>
        /// 支付方式(0代表货到付款,1代表在线支付)
        /// </summary>
        public int PayMode { get; set; }

        /// <summary>
        /// 默认完整用户配送地址
        /// </summary>
        public FullShipAddressInfo DefaultFullShipAddressInfo { get; set; }

        /// <summary>
        /// 支付积分名称
        /// </summary>
        public string PayCreditName { get; set; }
        /// <summary>
        /// 用户支付积分
        /// </summary>
        public int UserPayCredits { get; set; }
        /// <summary>
        /// 最大使用支付积分
        /// </summary>
        public int MaxUsePayCredits { get; set; }
        /// <summary>
        /// 每100积分相当多少元
        /// </summary>
        public int PayCreditPrice { get; set; }

        /// <summary>
        /// 全部配送费用
        /// </summary>
        public int AllShipFee { get; set; }
        /// <summary>
        /// 全部满减
        /// </summary>
        public int AllFullCut { get; set; }
        /// <summary>
        /// 全部商品合计
        /// </summary>
        public decimal AllProductAmount { get; set; }
        /// <summary>
        /// 全部订单合计
        /// </summary>
        public decimal AllOrderAmount { get; set; }

        /// <summary>
        /// 全部商品总数量
        /// </summary>
        public int AllTotalCount { get; set; }
        /// <summary>
        /// 全部商品总重量
        /// </summary>
        public int AllTotalWeight { get; set; }
        /// <summary>
        /// 店铺订单列表
        /// </summary>
        public List<StoreOrder> StoreOrderList { get; set; }
        /// <summary>
        /// 商户折扣
        /// </summary>
        public decimal Discount { get; set; } = 0;
        /// <summary>
        /// 会员折扣
        /// </summary>
        public int RankDiscount { get; set; } = 0;
        /// <summary>
        /// 会员折扣金额
        /// </summary>
        public decimal RankDiscountMoney { get; set; } = 0;
    }

    /// <summary>
    /// 订单模型
    /// </summary>
    public class OrderModel
    {
        public int Oid { get; set; }
        public string OSN { get; set; }
        public string Sid { get; set; }
        public int Uid { get; set; }
        public int OrderState { get; set; }
        //public decimal ProductAmount { get; set; }
        public decimal OrderAmount { get; set; }
        public decimal SurplusMoney { get; set; }
        public int IsReview { get; set; }
        public DateTime AddTime { get; set; }
        public int StoreId { get; set; }
        public string StoreName { get; set; }
        public int PayMode { get; set; }
        public int RegionId { get; set; }
        public string Consignee { get; set; }
        /// <summary>
        /// 预定开始时间
        /// </summary>
        public DateTime BookStartTime { get; set; }

        /// <summary>
        /// 预定结束时间
        /// </summary>
        public DateTime BookEndTime { get; set; }
        //public string Mobile { get; set; }
        //public string Phone { get; set; }
        //public string Email { get; set; }
        //public string ZipCode { get; set; }
        //public string Address { get; set; }
        //public string UserName { get; set; }
        //public string ProvinceName { get; set; }
        //public string CityName { get; set; }
        //public string CountyName { get; set; }
        /// <summary>
        /// 订单状态(0全部,20 待付款,40 确认中,60 已确认,80 备货中,100 已发货,120 已收货,140 锁定,160 取消)
        /// </summary>
        public string StatusStr {
            get
            {
                switch (OrderState)
                {
                    case 20:
                        return "待付款";
                    case 40:
                        return "确认中";
                    case 60:
                        return "已确认";
                    case 80:
                        return "备货中";
                    case 100:
                        return "已发货";
                    case 120:
                        return "已收货";
                    case 140:
                        return "已锁定";
                    case 160:
                        return "已取消";
                    default:
                        return "未知";
                }
            }
        }

        public List<OrderProductInfo> ProductInfos { get; set; }




    }
    /// <summary>
    /// 订单产品模型
    /// </summary>
    public class OrderProductModel
    {
        public int Pid { get; set; }
        /// <summary>
        /// 产品名称
        /// </summary>
        public string Name { get; set; }
    }

    /// <summary>
    /// 订单列表模型
    /// </summary>
    public class OrderListModel
    {

        /// <summary>
        /// 分页对象
        /// </summary>
        public PageModel PageModel { get; set; }
        /// <summary>
        /// 订单列表
        /// </summary>
        public DataTable OrderList { get; set; }
        /// <summary>
        /// 订单编号
        /// </summary>
        public string OSN { get; set; }
        /// <summary>
        /// 账户名
        /// </summary>
        public string AccountName { get; set; }
        /// <summary>
        /// 收货人
        /// </summary>
        public string Consignee { get; set; }
        /// <summary>
        /// 订单状态
        /// </summary>
        public int OrderState { get; set; }
        /// <summary>
        /// 订单状态列表
        /// </summary>
        public List<OrderStateModel> OrderStateList { get; set; }

    }
    /// <summary>
    /// 订单状态
    /// </summary>
    public class OrderStateModel
    {
        /// <summary>
        /// 显示名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 状态值
        /// </summary>
        public string Value { get; set; }
    }

    /// <summary>
    /// 订单详情实体
    /// </summary>
    public class OrderInfoModel
    {
        /// <summary>
        /// 订单信息
        /// </summary>
        public OrderInfo OrderInfo { get; set; }
        /// <summary>
        /// 区域信息
        /// </summary>
        public RegionInfo RegionInfo { get; set; }
        /// <summary>
        /// 订单备注信息
        /// </summary>
        public List<OrderActionInfo> OrderActionInfo { get; set; }
        /// <summary>
        /// 订单商品列表
        /// </summary>
        public List<OrderProductDetailModel> OrderProductList { get; set; }

        /// <summary>
        /// 支付方式 
        /// </summary>
        public Dictionary<string, object> PayInfo { get; set; }
    }
    /// <summary>
    /// 扩展
    /// </summary>
    public class OrderProductDetailModel
    {
        public OrderProductInfo Info { get; set; }
        public List<ExtProductSKUItemInfo> SkuItemList { get; set; }
        public string SkuLabel {
            get
            {
                var r = string.Empty;
                if (SkuItemList == null) return r;
                foreach (var item in SkuItemList)
                {
                    r += item.AttrName + ":";
                    if (item.IsInput == 1)
                        r += item.InputValue + " ";
                    else
                        r += item.AttrValue + " ";
                }
                return r;
            }
        }


    }
    public class DirectPaymentListModel
    {
        /// <summary>
        /// 分页对象
        /// </summary>
        public PageModel PageModel { get; set; }
        /// <summary>
        /// 订单列表
        /// </summary>
        public IList<DirectPaymentModel> OrderList { get; set; }
        

    }
    public class DirectPaymentModel
    {
        /// <summary>
        /// 主键
        /// </summary>
        public int Pid { get; set; }
        /// <summary>
        /// 订单号
        /// </summary>
        public string PSN { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
        public PartUserInfo User { get; set; }
        /// <summary>
        /// 支付状态0:待支付，1：已支付
        /// </summary>
        public int OrderState { get; set; }
        /// <summary>
        /// 订单金额
        /// </summary>
        public decimal OrderAmount { get; set; }
        /// <summary>
        /// 剩余支付金额
        /// </summary>
        public decimal SurplusMoney { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime AddTime { get; set; }
        /// <summary>
        ///店铺ID
        /// </summary>
        public int StoreId { get; set; }
        /// <summary>
        /// 支付流水号
        /// </summary>
        public string PaySN { get; set; }
        /// <summary>
        /// 支付时间
        /// </summary>
        public DateTime PayTime { get; set; }
        /// <summary>
        /// 支付系统名称
        /// </summary>
        public string PaySystemName { get; set; }

        /// <summary>
        /// 消耗积分数量
        /// </summary>
        public int PayCreditCount { get; set; }
        /// <summary>
        /// 积分换算后的金额
        /// </summary>
        public decimal PayCreditMoney { get; set; }
        /// <summary>
        /// 优惠券金额
        /// </summary>
        public decimal CouponMoney { get; set; }
        /// <summary>
        /// 余额支付的金额
        /// </summary>
        public decimal PayCash { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DirectPaymentModel()
        {
            PSN = string.Empty;
            OrderState = 0;
            OrderAmount = SurplusMoney = PayCreditMoney = CouponMoney = PayCash = 0;
            AddTime = PayTime = new DateTime(1900, 1, 1);
            StoreId = 0;
            PaySN = PaySystemName = string.Empty;
            PayCreditCount = 0;

        }
    }
    /// <summary>
    /// 打印订单模型类
    /// </summary>
    public class PrintOrderModel
    {
        /// <summary>
        /// 订单信息
        /// </summary>
        public OrderInfo OrderInfo { get; set; }
        /// <summary>
        /// 区域信息
        /// </summary>
        public RegionInfo RegionInfo { get; set; }
        /// <summary>
        /// 订单商品列表
        /// </summary>
        public List<PrintOrderProductInfo> OrderProductList { get; set; }
        /// <summary>
        /// 打印机设置
        /// </summary>
        public List<PrintConfig> PrintConfigList { get; set; }
    }

    public class PrintOrderProductInfo : OrderProductInfo
    {
        /// <summary>
        /// 当前商品所有SKU列表
        /// </summary>
        public List<ExtProductSKUItemInfo> CurrProductSkuList { get; set; }
        /// <summary>
        /// 餐桌信息
        /// </summary>
        public DiningTable DiningTable { get; set; }
    }

}
